package com.helloniu.fl.util {

import flash.utils.getDefinitionByName;
import flash.utils.getQualifiedClassName;

public class Class2 {
    public static function newInstance(clazz:String):Object {
        var clz:Class = forName(clazz);
        return new clz();
    }
    
    public static function newInstance2(clazz:Class):Object {
        return new clazz();
    }

    public static function forName(clazz:String):Class {
        return getDefinitionByName(clazz) as Class;
    }

    public static function getClassName(obj:Object):String {
        var clzname:String = getQualifiedClassName(obj);
        var clzarr:Array = clzname.split("::");
        clzname = clzarr[0] + "." + clzarr[1];
        return clzname;
    }

    public static function getClass(obj:Object):Class {
        var clzname:String = getQualifiedClassName(obj);
        var clzarr:Array = clzname.split("::");
        clzname = clzarr[0] + "." + clzarr[1];
        return forName(clzname);
    }
}
}